package com.example.jianzhioffer;

import java.util.Scanner;

/**
 * Created by Quincy on 2018/9/10.
 * 一个数组，找到后面的数减前面的数的最大值
 */
public class ArrayFindMax {
    static int[] arr = null;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String[] str = sc.nextLine().split(" ");
        arr = new int[str.length];
        for (int i = 0 ; i < str.length; i++){
            if (str[i] != null)
                arr[i] = Integer.parseInt(str[i]);
        }
        findMax(arr);

        System.out.println(getMaxDif(arr));

//        while( sc.hasNext()){
//            arr[] = sc.nextInt();
//        }
    }



    public static void findMax(int[] arr){
        int n = arr.length - 1;
        int maxIndex = 0;
        int maxVal = Integer.MIN_VALUE;
        int chaZhi;
        for (;n > 0; n --){
            chaZhi = arr[n] - arr[n - 1];
            if (chaZhi > maxVal){
                maxVal = chaZhi;
                maxIndex = n;
            }
        }
        System.out.println(maxVal);
    }

    static int getMaxDif(int[] arr){
        int n = arr.length;
        if (arr == null || n < 1 ){
            return 0;
        }
        int min = arr[0];
        int ans = Integer.MIN_VALUE;
        for(int i = 1 ; i < n; i++){
            min = Math.min(arr[i], min);
            ans = Math.max(arr[i] - min, ans);
        }
        return ans;
    }
}
